use ".data\clean\laneuse_dataset_040215.dta", clear
*drop if dow==0 | dow==6
keep if acct_type=="PRIVATE"
keep if entry_plaza!=exit_plaza
keep if charged_toll!=0
keep if acct_no!=""

drop if holiday==1
g speed=ELspeed
drop if speed<1
drop month
g month=month(date)
capture drop year
g year=year(date)
keep speed month hour year date min
*collapse (p50) p50_speed=speed (p20) p20_speed=speed, by(month hour year)
g fwy=10
g dir="W"
tempfile temp1
save `temp1'

use ".data\clean\laneuse_dataset_2dec14_I110S.dta", clear
*drop if dow==0 | dow==6
keep if acct_type=="PRIVATE"
keep if entry_plaza!=exit_plaza
keep if charged_toll!=0
keep if acct_no!=.

drop if holiday==1
g speed=ELspeed
drop if speed<1
drop month
g month=month(date)
capture drop year
g year=year(date)
keep speed month hour year date min
*collapse (p50) p50_speed=speed (p20) p20_speed=speed, by(month hour year)
g fwy=110
capture g dir="S"
tempfile temp2
save `temp2'
use ".data\clean\laneuse_dataset_01dec14_I110N.dta", clear
*drop if dow==0 | dow==6
keep if acct_type=="PRIVATE"
keep if entry_plaza!=exit_plaza
keep if charged_toll!=0
keep if acct_no!=.


drop if holiday==1
g speed=ELspeed
drop if speed<1
drop month
g month=month(date)
capture drop year
g year=year(date)
keep speed month hour year date min
*collapse (p50) p50_speed=speed (p20) p20_speed=speed, by(month hour year)
g fwy=110
capture g dir="N"
tempfile temp3
save `temp3'
use ".data\clean\I10E_laneuse_dataset_19nov14_wcensus.dta", clear
*drop if dow==0 | dow==6
keep if acct_type=="PRIVATE"
keep if entry_plaza!=exit_plaza
keep if charged_toll!=0
keep if acct_no!=""

drop if holiday==1
g speed=ELspeed
drop if speed<1
drop month
g month=month(date)
capture drop year
g year=year(date)
keep speed month hour year date min
*collapse speed, by(month hour date min year)
g fwy=10
capture g dir="E"
append using `temp1'
append using `temp2'
append using `temp3'
g speedHV=cond(type=="HV",speed,.)
g speedML=cond(type=="ML",speed,.)
collapse (p50) p50_speedHV=speedHV p50_speedML=speedML (p20) p20_speedHV=speedHV p20_speedML=speedML, by(fwy dir hour date)
save ".data\clean\HV_ML_reliab_040315.dta", replace
keep if dir=="W"
save ".data\clean\I10W_HV_ML_reliab_040315.dta", replace
